package StudyCode.summary.Basic.stringtokenizer;

import java.util.StringTokenizer;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class StringTokenizerUsing {
	public static void main(String[] args) {

		String src = "Hello World By Java";
		String src1 = "Hello-World-By-Java";

		System.out.println("用法1:");
		StringTokenizer stringTokenizer = new StringTokenizer(src);
		while (stringTokenizer.hasMoreTokens()) {
			System.out.println(stringTokenizer.nextToken());
		}

		System.out.println("用法2:");
		stringTokenizer = new StringTokenizer(src1, "-");
		while (stringTokenizer.hasMoreTokens()) {
			System.out.println(stringTokenizer.nextToken());
		}

		System.out.println("用法3:");
		stringTokenizer = new StringTokenizer(src1, "-", true);
		while (stringTokenizer.hasMoreTokens()) {
			System.out.println(stringTokenizer.nextToken());
		}
	}
}
